{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ddab128e",
   "metadata": {},
   "source": [
    "----------\n",
    "* 2022/9/5 / week03\n",
    "* python学习记录"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c52eb35",
   "metadata": {},
   "source": [
    "# 本周学习目标\n",
    "\n",
    "\n",
    "> 1.模块\n",
    "\n",
    "> 2.变量\n",
    "\n",
    "> 3.循环变量\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23defefd",
   "metadata": {},
   "source": [
    "# 1.模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "936dccdc",
   "metadata": {},
   "source": [
    "## 1. 1模块（标准库）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6557d1cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8e9c3f38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1662345818.1217248"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 纪元（1970.1.1）\n",
    "# 时间戳\n",
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "41d43df8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=5, tm_hour=10, tm_min=47, tm_sec=6, tm_wday=0, tm_yday=248, tm_isdst=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d75d11e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=5, tm_hour=2, tm_min=48, tm_sec=0, tm_wday=0, tm_yday=248, tm_isdst=0)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6403ad93",
   "metadata": {},
   "source": [
    "## 1.2模块 (开源模块)\n",
    "\n",
    "> 1.因为代码开源\n",
    "\n",
    "> 2.集合全领域（全人类）的需求\n",
    "\n",
    "> 3.按照国际标准开放的模块库\n",
    "\n",
    "> 资源地址http://pypi.org/\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d98994f2",
   "metadata": {},
   "source": [
    "## 1.3模块（自定义模块）\n",
    "> 1.不愿意开源的有一定只是产权的（开放API租用形式开放）\n",
    "> 2.自己用，写的也不那么好，开源出去丢人的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35776caf",
   "metadata": {},
   "source": [
    "# 2.变量\n",
    "> 1.声明变量（命名）\n",
    "> 2.规则\n",
    ">> A.变量名只能是字母、数字或者下划线的任意组合\n",
    ">> B.变量名的第一个字符不能是是数字\n",
    ">> C.以下关键字不能声明为变量[and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,not,or,pass,print,raise,return,try,while,with,yield]在jupyter中显示绿色不能命名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3a5265c3",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_name = \"Xiao Hong\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dca94231",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Xiao Hong'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cc08d31e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1743106181872"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网三_01_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "975fa36a",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (509544469.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [4]\u001b[1;36m\u001b[0m\n\u001b[1;33m    1网三 = \"xiaoming\"\u001b[0m\n\u001b[1;37m     ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "1网三 = \"xiaoming\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f398ae5b",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_age = 19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4107a6eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01_age"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ea52273f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "180000001 180000001\n"
     ]
    }
   ],
   "source": [
    "# 案例（关于变量）\n",
    "网三_01_ID = \"180000001\"\n",
    "网三_02_ID = 网三_01_ID\n",
    "print(网三_01_ID,网三_02_ID)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7c1b45d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "180000001 180000001\n",
      "180000006 180000001\n"
     ]
    }
   ],
   "source": [
    "网三_01_ID = \"180000001\"\n",
    "网三_02_ID = 网三_01_ID\n",
    "print(网三_01_ID,网三_02_ID)\n",
    "网三_01_ID = \"180000006\"\n",
    "print(网三_01_ID,网三_02_ID)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0f6062a3",
   "metadata": {},
   "source": [
    "## 课后作业\n",
    "* 课本p4项目练习（写一遍运行成功）\n",
    "* 思考if是什么？\n",
    "* 思考from是什么？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ad31a341",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"this minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an add minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7ab34858",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
